package com.du.stutestsys.config;

import org.springframework.amqp.core.ExchangeBuilder;
//import org.springframework.amqp.rabbit.annotation.Exchange;
//import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.amqp.core.*;
@Configuration
public class RabbitMqConfig {
    //创建交换机
    @Bean("topicExchange")
    public Exchange topicExchange() {
        return ExchangeBuilder.topicExchange("boot_exchange").durable(true).build();
    }

    //队列
    @Bean
    public Queue bootQueue() {
        return QueueBuilder.durable("boot_exchange").build();
    }

    //队列和交换机绑定关系
    @Bean
    public Binding bindQueueExchange(@Qualifier("bootQueue") Queue queue,
                                     @Qualifier("topicExchange") Exchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with("boot").noargs();
    }
}